
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>左右布局右侧吸附案例</title>
    <style>
        body {
            margin: 0;
            font-family: Arial, sans-serif;
        }
        .container {
            display: flex;
            min-height: 200vh; /* 增加高度测试滚动 */
        }
        .left {
            width: 70%;
            background: #f5f5f5;
            padding: 20px;
        }
        .right {
            width: 30%;
            padding: 20px;
            background: #e0e0e0;
            position: sticky;
            top: 0;
            align-self: flex-start; /* 防止高度拉伸 */
            height: 100vh; /* 保持与视口同高 */
            overflow-y: auto; /* 允许独立滚动 */
        }
        .content-block {
            height: 300px;
            margin-bottom: 20px;
            background: #fff;
            border: 1px solid #ddd;
            padding: 15px;
        }
    </style>
</head>
<body>
    <div >
        <div >
            <div class="content-block">
                <h2 id="md-editor-v3">md-editor-v3</h2>
                <h3 id="基本演示">基本演示</h3>
                <h3 id="代码演示">代码演示</h3>
                <h3 id="文本演示">文本演示</h3>
                <h3 id="表格演示">表格演示</h3>
            </div>
        </div>
    </div>
    <div class="container">
        <div class="left">
            <div class="content-block">左侧内容区块1</div>
            <div class="content-block">左侧内容区块2</div>
            <div class="content-block">左侧内容区块3</div>
        </div>
        <div class="right">
            <h3>吸附侧边栏</h3>
            <p>滚动页面时，此区域会保持固定位置</p>
            <div style="height: 800px; background: #eee; padding: 10px;">
                可独立滚动的内容区域
            </div>
        </div>
    </div>
</body>
</html>
